
class R implements Runnable{
    private int tickets=5;

    @Override
    public void run() {
        while (tickets>0){
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(Thread.currentThread().getName()+"卖出票，门票还剩"+tickets--+"张");
        }
    }
}
public class Test {
    public static void main(String[] args) {
        R r=new R();
        new Thread(r,"窗口一").start();
        new Thread(r,"窗口二").start();
        new Thread(r,"窗口三").start();
    }
}
